package com.ruoyi.web.controller.dispatch;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DispatchIndex;
import com.ruoyi.system.service.IDispatchIndexService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 调度首页信息Controller
 * 
 * @author ruoyi
 * @date 2025-03-02
 */
@RestController
@RequestMapping("/system/dispatchIndex")
public class DispatchIndexController extends BaseController
{
    @Autowired
    private IDispatchIndexService dispatchIndexService;

    /**
     * 查询调度首页信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchIndex:list')")
    @GetMapping("/list")
    public TableDataInfo list(DispatchIndex dispatchIndex)
    {
        startPage();
        List<DispatchIndex> list = dispatchIndexService.selectDispatchIndexList(dispatchIndex);
        return getDataTable(list);
    }

    /**
     * 导出调度首页信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchIndex:export')")
    @Log(title = "调度首页信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DispatchIndex dispatchIndex)
    {
        List<DispatchIndex> list = dispatchIndexService.selectDispatchIndexList(dispatchIndex);
        ExcelUtil<DispatchIndex> util = new ExcelUtil<DispatchIndex>(DispatchIndex.class);
        util.exportExcel(response, list, "调度首页信息数据");
    }

    /**
     * 获取调度首页信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchIndex:query')")
    @GetMapping(value = "/{dispatchIndexId}")
    public AjaxResult getInfo(@PathVariable("dispatchIndexId") Long dispatchIndexId)
    {
        return success(dispatchIndexService.selectDispatchIndexByDispatchIndexId(dispatchIndexId));
    }

    /**
     * 新增调度首页信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchIndex:add')")
    @Log(title = "调度首页信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DispatchIndex dispatchIndex)
    {
        return toAjax(dispatchIndexService.insertDispatchIndex(dispatchIndex));
    }

    /**
     * 修改调度首页信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchIndex:edit')")
    @Log(title = "调度首页信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DispatchIndex dispatchIndex)
    {
        return toAjax(dispatchIndexService.updateDispatchIndex(dispatchIndex));
    }

    /**
     * 删除调度首页信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchIndex:remove')")
    @Log(title = "调度首页信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dispatchIndexIds}")
    public AjaxResult remove(@PathVariable Long[] dispatchIndexIds)
    {
        return toAjax(dispatchIndexService.deleteDispatchIndexByDispatchIndexIds(dispatchIndexIds));
    }
}
